package org.example.controller;

import org.example.domain.Room;
import org.example.service.RoomService;
import org.example.util.Result;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/room")
public class RoomController {
    @Resource
    private RoomService roomService;
//    房间列表
    @GetMapping("/listRoom")
    public Result listRoom(){
        return Result.OK(roomService.list());
    }
//    房间的逻辑删除
    @GetMapping("/del")
    public Result del(@RequestParam("rid") Integer rid){
        return Result.OK(roomService.removeById(rid));
    }
    @Transactional
    @PostMapping("/add")
    public Boolean add(@RequestBody Room room){

        return roomService.save(room);
    }

}
